package com.example.boxugu.myapplication.activity;

import android.support.constraint.ConstraintLayout;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import com.example.boxugu.myapplication.Fragment.CourseFragment;
import com.example.boxugu.myapplication.Fragment.MyFragment;
import com.example.boxugu.myapplication.Fragment.PracticeFragment;
import com.example.boxugu.myapplication.R;

public class MainActivity extends AppCompatActivity {
    ConstraintLayout mMybtn;
    ConstraintLayout mCourse;
    ConstraintLayout mPractice;
    Fragment myfragment=new MyFragment();
    Fragment coursefragment=new CourseFragment();
    Fragment practiceFragment=new PracticeFragment();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getSupportFragmentManager().beginTransaction().replace(R.id.myRlout,coursefragment).commit();
        mMybtn=findViewById(R.id.c4);
        mMybtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("MainActivity","mMybtn");
                getSupportFragmentManager().beginTransaction().replace(R.id.myRlout,myfragment).commit();
                mMybtn.setSelected(true);
                mCourse.setSelected(false);
                mPractice.setSelected(false);

            }
        });
        mCourse=findViewById(R.id.c2);
        mCourse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("MainActivity","mCourse");
                getSupportFragmentManager().beginTransaction().replace(R.id.myRlout,coursefragment).commit();
                mCourse.setSelected(true);
                mMybtn.setSelected(false);
                mPractice.setSelected(false);
            }
        });
        mPractice=findViewById(R.id.c3);
        mCourse.setSelected(true);
        mMybtn.setSelected(false);
        mPractice.setSelected(false);
        mPractice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("MainActivity","mPractice");
                getSupportFragmentManager().beginTransaction().replace(R.id.myRlout,practiceFragment).commit();
                mPractice.setSelected(true);
                mCourse.setSelected(false);
                mMybtn.setSelected(false);

            }
        });
    }
    @Override
    protected void onResume() {
        super.onResume();
    }
}
